﻿Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Localization

Namespace Disgrafic.DotNetNuke.DGSchedulerDashboard

	Partial Class LateTasks
		Inherits PortalModuleBase

		Protected Function ParseTime(ByVal minutesTotal As Integer) As String

			Dim days As Integer
			Dim hours As Integer
			Dim minutes As Integer

			days = minutesTotal / 1440
			hours = (minutesTotal - days * 1440) / 60
			minutes = (minutesTotal - days * 1440 - hours * 60)

			If days > 0 Then
				Return String.Format(Localization.GetString("FormatDays", LocalResourceFile), minutes, hours, days)
			ElseIf hours > 0 Then
				Return String.Format(Localization.GetString("FormatHours", LocalResourceFile), minutes, hours)
			Else
				Return String.Format(Localization.GetString("FormatMins", LocalResourceFile), minutes)
			End If
		End Function

		Private Sub BindData()

			Localization.LocalizeGridView(grTasks, LocalResourceFile)
			grTasks.DataSource = Disgrafic.DotNetNuke.DGSchedulerDashboard.DelayedTasksController.GetData(Integer.Parse(txtThreshold.Text), chkActive.Checked, Integer.Parse(txtDays.Text))
			grTasks.DataBind()

		End Sub

		Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

			If Not Page.IsPostBack Then
				BindData()
			End If

		End Sub

		Protected Sub btFilter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btFilter.Click
			BindData()
		End Sub

	End Class

End Namespace
